package com.wanshi.cloud.controller;


import com.wanshi.cloud.service.IUserService;
import com.wanshi.cloud.utils.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 顽石教育-www.wanshi.com
 * @since 2021-09-02
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;


    //1 根据id 查询用户
    @GetMapping("/{id}")
    public Result findById(@PathVariable("id") Integer id){
        return userService.findById(id);
    }


    //2 查询所有用户
    @GetMapping("/list")
    public Result findAll(){
        return userService.findAll();
    }


    //3 分页
    @GetMapping("/page/{page}/{size}")
    public Result findByPage(@PathVariable("page") Integer page,
                             @PathVariable("size") Integer size){
        return userService.findByPage(page,size);
    }


}
